/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author user
 */
@Entity
@Table(name = "invitation")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Invitation.findAll", query = "SELECT i FROM Invitation i"),
    @NamedQuery(name = "Invitation.findById", query = "SELECT i FROM Invitation i WHERE i.id = :id"),
    @NamedQuery(name = "Invitation.findByDateTime", query = "SELECT i FROM Invitation i WHERE i.dateTime = :dateTime"),
    @NamedQuery(name = "Invitation.findByStatus", query = "SELECT i FROM Invitation i WHERE i.status = :status"),
    @NamedQuery(name = "Invitation.findByReceiverUsername", query = "SELECT i FROM Invitation i WHERE i.receiverUsername = :receiverUsername"),
    @NamedQuery(name = "Invitation.findBySenderEmail", query = "SELECT i FROM Invitation i WHERE i.senderEmail = :senderEmail"),
    @NamedQuery(name = "Invitation.findByReceiverEmail", query = "SELECT i FROM Invitation i WHERE i.receiverEmail = :receiverEmail")})
public class Invitation implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @Column(name = "DateTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateTime;
    @Size(max = 45)
    @Column(name = "Status")
    private String status;
    @Size(max = 45)
    @Column(name = "Receiver_Username")
    private String receiverUsername;
    @Size(max = 155)
    @Column(name = "Sender_Email")
    private String senderEmail;
    @Size(max = 155)
    @Column(name = "Receiver_Email")
    private String receiverEmail;
    @JoinColumn(name = "Event_ID", referencedColumnName = "ID")
    @ManyToOne
    private Event eventID;
    @JoinColumn(name = "Sender_Username", referencedColumnName = "Username")
    @ManyToOne
    private User senderUsername;

    public Invitation() {
    }

    public Invitation(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDateTime() {
        return dateTime;
    }

    public void setDateTime(Date dateTime) {
        this.dateTime = dateTime;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getReceiverUsername() {
        return receiverUsername;
    }

    public void setReceiverUsername(String receiverUsername) {
        this.receiverUsername = receiverUsername;
    }

    public String getSenderEmail() {
        return senderEmail;
    }

    public void setSenderEmail(String senderEmail) {
        this.senderEmail = senderEmail;
    }

    public String getReceiverEmail() {
        return receiverEmail;
    }

    public void setReceiverEmail(String receiverEmail) {
        this.receiverEmail = receiverEmail;
    }

    public Event getEventID() {
        return eventID;
    }

    public void setEventID(Event eventID) {
        this.eventID = eventID;
    }

    public User getSenderUsername() {
        return senderUsername;
    }

    public void setSenderUsername(User senderUsername) {
        this.senderUsername = senderUsername;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Invitation)) {
            return false;
        }
        Invitation other = (Invitation) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Invitation[ id=" + id + " ]";
    }
    
}
